<template>
  <div>
    <h1>App...</h1>
    <p>{{ num }}</p>
    <Father />
  </div>
</template>

<script>
import Father from "./views/Father";

export default {
  name: "App",
  data() {
    return {
      num: 0,
    };
  },
  mounted() {
    // console.log(this.$globalEventBus);
    // 绑定事件：接受数据方、被修改数据方
    this.$globalEventBus.$on("add", this.add);
  },
  beforeDestroy() {
    this.$globalEventBus.$off("add", this.add);
  },
  methods: {
    add(x, ...rest) {
      console.log(rest);
      this.num += x;
    },
  },
  components: {
    Father,
  },
};
</script>

<style>
</style>
